package cn.iocoder.yudao.module.carbon.dal.mysql.gwp;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.carbon.api.gwp.dto.GwpListReqDTO;
import cn.iocoder.yudao.module.carbon.controller.admin.gwp.vo.GwpExportReqVO;
import cn.iocoder.yudao.module.carbon.controller.admin.gwp.vo.GwpPageReqVO;
import cn.iocoder.yudao.module.carbon.dal.dataobject.gwp.GwpDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 全球变暖潜能值 Mapper
 *
 * @author StevenShen
 */
@Mapper
public interface GwpMapper extends BaseMapperX<GwpDO> {

    default PageResult<GwpDO> selectPage(GwpPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GwpDO>()
                .eqIfPresent(GwpDO::getGaseId, reqVO.getGaseId())
                .eqIfPresent(GwpDO::getReportVersion, reqVO.getReportVersion())
                .eqIfPresent(GwpDO::getGwp, reqVO.getGwp())
                .orderByDesc(GwpDO::getId));
    }

    default List<GwpDO> selectList(GwpExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GwpDO>()
                .eqIfPresent(GwpDO::getGaseId, reqVO.getGaseId())
                .eqIfPresent(GwpDO::getReportVersion, reqVO.getReportVersion())
                .eqIfPresent(GwpDO::getGwp, reqVO.getGwp())
                .orderByDesc(GwpDO::getId));
    }

    default List<GwpDO> selectList(GwpListReqDTO reqDTO) {
        return selectList(new LambdaQueryWrapperX<GwpDO>()
                .eqIfPresent(GwpDO::getReportVersion, reqDTO.getReportVersion())
                .orderByDesc(GwpDO::getId));
    }

}
